home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / WWW / Perl_WWW_Utilities / MHonArc / lib / qprint.pl < prev    next >
Encoding:
Perl Script  |  1996-01-03  |  1.6 KB  |  45 lines

  1. ##---------------------------------------------------------------------------##
  2. ##  File:
  3. ##      quoted_printable.pl
  4. ##  Authors:
  5. ##      Earl Hood       ehood@convex.com
  6. ##    Alan Barrett    barrett@daisy.ee.und.ac.za
  7. ##  Description:
  8. ##    This library defines the routine to decode "quoted-printable"
  9. ##    encoded data.
  10. ##    Usage:
  11. ##        require "quoted_printable.pl";
  12. ##        $text = "ed_printable'qprdecode($data);
  13. ##
  14. ##---------------------------------------------------------------------------##
  15. ##    Copyright (C) 1995    Earl Hood, ehood@convex.com
  16. ##
  17. ##    This program is free software; you can redistribute it and/or modify
  18. ##    it under the terms of the GNU General Public License as published by
  19. ##    the Free Software Foundation; either version 2 of the License, or
  20. ##    (at your option) any later version.
  21. ##
  22. ##    This program is distributed in the hope that it will be useful,
  23. ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25. ##    GNU General Public License for more details.
  26. ##
  27. ##    You should have received a copy of the GNU General Public License
  28. ##    along with this program; if not, write to the Free Software
  29. ##    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30. ##---------------------------------------------------------------------------##
  31.  
  32.  
  33. package quoted_printable;
  34.  
  35. sub qprdecode {
  36.     local($_) = shift;
  37.  
  38.     s/[^\S\r\n]*(\r?\n)/$1/g;    # remove trailing whitespace on each line
  39.     s/\=\r?\n//g;        # remove soft linebreaks
  40.     s/=(..)/pack("H2",$1)/ge;    # convert hex codes
  41.     $_;                # return result
  42. }
  43.  
  44. 1;
  45.